with Interfaces.C; use Interfaces.C;
with SDL_stdinc_h;
with SDL_keyboard_h;
with System;

package SDL_events_h is


  SDL_RELEASED : constant := 0;  --  SDL_events.h:43
  SDL_PRESSED : constant := 1;  --  SDL_events.h:44
  --  arg-macro: function SDL_EVENTMASK (X)
  --    return 2**(X);

  SDL_ALLEVENTS : constant := 16#FFFFFFFF#;  --  SDL_events.h:109

  SDL_QUERY : constant := -1;  --  SDL_events.h:324
  SDL_IGNORE : constant := 0;  --  SDL_events.h:325
  SDL_DISABLE : constant := 0;  --  SDL_events.h:326
  SDL_ENABLE : constant := 1;  --  SDL_events.h:327

  --    SDL - Simple DirectMedia Layer
  --    Copyright (C) 1997-2006 Sam Lantinga
  --    This library is free software; you can redistribute it and/or
  --    modify it under the terms of the GNU Lesser General Public
  --    License as published by the Free Software Foundation; either
  --    version 2.1 of the License, or (at your option) any later version.
  --    This library is distributed in the hope that it will be useful,
  --    but WITHOUT ANY WARRANTY; without even the implied warranty of
  --    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  --    Lesser General Public License for more details.
  --    You should have received a copy of the GNU Lesser General Public
  --    License along with this library; if not, write to the Free Software
  --    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  --    Sam Lantinga
  --    slouken@libsdl.org
  --

  -- Include file for SDL event handling
  -- Set up for C function definitions, even when using C++
  -- General keyboard/mouse state definitions
  -- Event enumerations
  -- Unused (do not remove)
  -- Application loses/gains visibility
  -- Keys pressed
  -- Keys released
  -- Mouse moved
  -- Mouse button pressed
  -- Mouse button released
  -- Joystick axis motion
  -- Joystick trackball motion
  -- Joystick hat position change
  -- Joystick button pressed
  -- Joystick button released
  -- User-requested quit
  -- System specific event
  -- Reserved for future use..
  -- Reserved for future use..
  -- User resized video mode
  -- Screen needs to be redrawn
  -- Reserved for future use..
  -- Reserved for future use..
  -- Reserved for future use..
  -- Reserved for future use..
  -- Reserved for future use..
  -- Reserved for future use..
  -- Events SDL_USEREVENT through SDL_MAXEVENTS-1 are for your use
  -- This last event is only for bounding internal arrays
  --	  It is the number of bits in the event mask datatype -- Uint32
  --

   subtype SDL_EventType is unsigned_char;
   SDL_NOEVENT : constant SDL_EventType := 0;
   SDL_ACTIVEEVENT : constant SDL_EventType := 1;
   SDL_KEYDOWN : constant SDL_EventType := 2;
   SDL_KEYUP : constant SDL_EventType := 3;
   SDL_MOUSEMOTION : constant SDL_EventType := 4;
   SDL_MOUSEBUTTONDOWN : constant SDL_EventType := 5;
   SDL_MOUSEBUTTONUP : constant SDL_EventType := 6;
   SDL_JOYAXISMOTION : constant SDL_EventType := 7;
   SDL_JOYBALLMOTION : constant SDL_EventType := 8;
   SDL_JOYHATMOTION : constant SDL_EventType := 9;
   SDL_JOYBUTTONDOWN : constant SDL_EventType := 10;
   SDL_JOYBUTTONUP : constant SDL_EventType := 11;
   SDL_QUIT : constant SDL_EventType := 12;
   SDL_SYSWMEVENT : constant SDL_EventType := 13;
   SDL_EVENT_RESERVEDA : constant SDL_EventType := 14;
   SDL_EVENT_RESERVEDB : constant SDL_EventType := 15;
   SDL_VIDEORESIZE : constant SDL_EventType := 16;
   SDL_VIDEOEXPOSE : constant SDL_EventType := 17;
   SDL_EVENT_RESERVED2 : constant SDL_EventType := 18;
   SDL_EVENT_RESERVED3 : constant SDL_EventType := 19;
   SDL_EVENT_RESERVED4 : constant SDL_EventType := 20;
   SDL_EVENT_RESERVED5 : constant SDL_EventType := 21;
   SDL_EVENT_RESERVED6 : constant SDL_EventType := 22;
   SDL_EVENT_RESERVED7 : constant SDL_EventType := 23;
   SDL_USEREVENT : constant SDL_EventType := 24;
   SDL_NUMEVENTS : constant SDL_EventType := 32;  -- SDL_events.h:78:3

  -- Predefined event masks
   subtype SDL_EventMask is unsigned;
   SDL_ACTIVEEVENTMASK : constant SDL_EventMask := 2;
   SDL_KEYDOWNMASK : constant SDL_EventMask := 4;
   SDL_KEYUPMASK : constant SDL_EventMask := 8;
   SDL_KEYEVENTMASK : constant SDL_EventMask := 12;
   SDL_MOUSEMOTIONMASK : constant SDL_EventMask := 16;
   SDL_MOUSEBUTTONDOWNMASK : constant SDL_EventMask := 32;
   SDL_MOUSEBUTTONUPMASK : constant SDL_EventMask := 64;
   SDL_MOUSEEVENTMASK : constant SDL_EventMask := 112;
   SDL_JOYAXISMOTIONMASK : constant SDL_EventMask := 128;
   SDL_JOYBALLMOTIONMASK : constant SDL_EventMask := 256;
   SDL_JOYHATMOTIONMASK : constant SDL_EventMask := 512;
   SDL_JOYBUTTONDOWNMASK : constant SDL_EventMask := 1024;
   SDL_JOYBUTTONUPMASK : constant SDL_EventMask := 2048;
   SDL_JOYEVENTMASK : constant SDL_EventMask := 3968;
   SDL_VIDEORESIZEMASK : constant SDL_EventMask := 65536;
   SDL_VIDEOEXPOSEMASK : constant SDL_EventMask := 131072;
   SDL_QUITMASK : constant SDL_EventMask := 4096;
   SDL_SYSWMEVENTMASK : constant SDL_EventMask := 8192;  -- SDL_events.h:108:3

  -- Application visibility event structure
  -- SDL_ACTIVEEVENT
   type t_SDL_ActiveEvent is record
      c_type : aliased SDL_stdinc_h.Uint8;  -- SDL_events.h:113:8
      gain : aliased SDL_stdinc_h.Uint8;  -- SDL_events.h:114:8
      state : aliased SDL_stdinc_h.Uint8;  -- SDL_events.h:115:8
   end record;
   pragma Convention (C, SDL_ActiveEvent);  -- SDL_events.h:112:32

  -- Whether given states were gained or lost (1/0)
  -- A mask of the focus states
  -- Keyboard event structure
  -- SDL_KEYDOWN or SDL_KEYUP
   type SDL_KeyboardEvent is record
      c_type : aliased SDL_stdinc_h.Uint8;  -- SDL_events.h:120:8
      which : aliased SDL_stdinc_h.Uint8;  -- SDL_events.h:121:8
      state : aliased SDL_stdinc_h.Uint8;  -- SDL_events.h:122:8
      keysym : aliased SDL_keyboard_h.SDL_keysym;  -- SDL_events.h:123:13
   end record;
   pragma Convention (C, SDL_KeyboardEvent);  -- SDL_events.h:119:34

  -- The keyboard device index
  -- SDL_PRESSED or SDL_RELEASED
  -- Mouse motion event structure
  -- SDL_MOUSEMOTION
   type SDL_MouseMotionEvent is record
      c_type : aliased SDL_stdinc_h.Uint8;  -- SDL_events.h:128:8
      which : aliased SDL_stdinc_h.Uint8;  -- SDL_events.h:129:8
      state : aliased SDL_stdinc_h.Uint8;  -- SDL_events.h:130:8
      x : aliased SDL_stdinc_h.Uint16;  -- SDL_events.h:131:9
      y : aliased SDL_stdinc_h.Uint16;  -- SDL_events.h:131:12
      xrel : aliased SDL_stdinc_h.Sint16;  -- SDL_events.h:132:9
      yrel : aliased SDL_stdinc_h.Sint16;  -- SDL_events.h:133:9
   end record;
   pragma Convention (C, SDL_MouseMotionEvent);  -- SDL_events.h:127:37

  -- The mouse device index
  -- The current button state
  -- The X/Y coordinates of the mouse
  -- The relative motion in the X direction
  -- The relative motion in the Y direction
  -- Mouse button event structure
  -- SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP
   type SDL_MouseButtonEvent is record
      c_type : aliased SDL_stdinc_h.Uint8;  -- SDL_events.h:138:8
      which : aliased SDL_stdinc_h.Uint8;  -- SDL_events.h:139:8
      button : aliased SDL_stdinc_h.Uint8;  -- SDL_events.h:140:8
      state : aliased SDL_stdinc_h.Uint8;  -- SDL_events.h:141:8
      x : aliased SDL_stdinc_h.Uint16;  -- SDL_events.h:142:9
      y : aliased SDL_stdinc_h.Uint16;  -- SDL_events.h:142:12
   end record;
   pragma Convention (C, SDL_MouseButtonEvent);  -- SDL_events.h:137:37

  -- The mouse device index
  -- The mouse button index
  -- SDL_PRESSED or SDL_RELEASED
  -- The X/Y coordinates of the mouse at press time
  -- Joystick axis motion event structure
  -- SDL_JOYAXISMOTION
   type SDL_JoyAxisEvent is record
      c_type : aliased SDL_stdinc_h.Uint8;  -- SDL_events.h:147:8
      which : aliased SDL_stdinc_h.Uint8;  -- SDL_events.h:148:8
      axis : aliased SDL_stdinc_h.Uint8;  -- SDL_events.h:149:8
      value : aliased SDL_stdinc_h.Sint16;  -- SDL_events.h:150:9
   end record;
   pragma Convention (C, SDL_JoyAxisEvent);  -- SDL_events.h:146:33

  -- The joystick device index
  -- The joystick axis index
  -- The axis value (range: -32768 to 32767)
  -- Joystick trackball motion event structure
  -- SDL_JOYBALLMOTION
   type SDL_JoyBallEvent is record
      c_type : aliased SDL_stdinc_h.Uint8;  -- SDL_events.h:155:8
      which : aliased SDL_stdinc_h.Uint8;  -- SDL_events.h:156:8
      ball : aliased SDL_stdinc_h.Uint8;  -- SDL_events.h:157:8
      xrel : aliased SDL_stdinc_h.Sint16;  -- SDL_events.h:158:9
      yrel : aliased SDL_stdinc_h.Sint16;  -- SDL_events.h:159:9
   end record;
   pragma Convention (C, SDL_JoyBallEvent);  -- SDL_events.h:154:33

  -- The joystick device index
  -- The joystick trackball index
  -- The relative motion in the X direction
  -- The relative motion in the Y direction
  -- Joystick hat position change event structure
  -- SDL_JOYHATMOTION
   type SDL_JoyHatEvent is record
      c_type : aliased SDL_stdinc_h.Uint8;  -- SDL_events.h:164:8
      which : aliased SDL_stdinc_h.Uint8;  -- SDL_events.h:165:8
      hat : aliased SDL_stdinc_h.Uint8;  -- SDL_events.h:166:8
      value : aliased SDL_stdinc_h.Uint8;  -- SDL_events.h:167:8
   end record;
   pragma Convention (C, SDL_JoyHatEvent);  -- SDL_events.h:163:32

  -- The joystick device index
  -- The joystick hat index
  -- The hat position value:
  --			    SDL_HAT_LEFTUP   SDL_HAT_UP       SDL_HAT_RIGHTUP
  --			    SDL_HAT_LEFT     SDL_HAT_CENTERED SDL_HAT_RIGHT
  --			    SDL_HAT_LEFTDOWN SDL_HAT_DOWN     SDL_HAT_RIGHTDOWN
  --			   Note that zero means the POV is centered.
  --

  -- Joystick button event structure
  -- SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP
   type SDL_JoyButtonEvent is record
      c_type : aliased SDL_stdinc_h.Uint8;  -- SDL_events.h:177:8
      which : aliased SDL_stdinc_h.Uint8;  -- SDL_events.h:178:8
      button : aliased SDL_stdinc_h.Uint8;  -- SDL_events.h:179:8
      state : aliased SDL_stdinc_h.Uint8;  -- SDL_events.h:180:8
   end record;
   pragma Convention (C, SDL_JoyButtonEvent);  -- SDL_events.h:176:35

  -- The joystick device index
  -- The joystick button index
  -- SDL_PRESSED or SDL_RELEASED
  -- The "window resized" event
  --   When you get this event, you are responsible for setting a new video
  --   mode with the new width and height.
  --

  -- SDL_VIDEORESIZE
   type SDL_ResizeEvent is record
      c_type : aliased SDL_stdinc_h.Uint8;  -- SDL_events.h:188:8
      w : aliased int;  -- SDL_events.h:189:6
      h : aliased int;  -- SDL_events.h:190:6
   end record;
   pragma Convention (C, SDL_ResizeEvent);  -- SDL_events.h:187:32

  -- New width
  -- New height
  -- The "screen redraw" event
  -- SDL_VIDEOEXPOSE
   type SDL_ExposeEvent is record
      c_type : aliased SDL_stdinc_h.Uint8;  -- SDL_events.h:195:8
   end record;
   pragma Convention (C, SDL_ExposeEvent);  -- SDL_events.h:194:32

  -- The "quit requested" event
  -- SDL_QUIT
   type SDL_QuitEvent is record
      c_type : aliased SDL_stdinc_h.Uint8;  -- SDL_events.h:200:8
   end record;
   pragma Convention (C, SDL_QuitEvent);  -- SDL_events.h:199:30

  -- A user-defined event type
  -- SDL_USEREVENT through SDL_NUMEVENTS-1
   type t_SDL_UserEvent is record
      c_type : aliased SDL_stdinc_h.Uint8;  -- SDL_events.h:205:8
      code : aliased int;  -- SDL_events.h:206:6
      data1 : System.Address;  -- SDL_events.h:207:8
      data2 : System.Address;  -- SDL_events.h:208:8
   end record;
   pragma Convention (C, SDL_UserEvent);  -- SDL_events.h:204:30

  -- User defined event code
  -- User defined data pointer
  -- User defined data pointer
  -- If you want to use this event, you should include SDL_syswm.h
   --  skipped empty struct SDL_SysWMmsg

   type t_SDL_SysWMEvent is record
      c_type : aliased SDL_stdinc_h.Uint8;  -- SDL_events.h:215:8
      msg : System.Address;  -- SDL_events.h:216:16
   end record;
   pragma Convention (C, SDL_SysWMEvent);  -- SDL_events.h:214:31

  -- General event structure
   type SDL_Event (discr : unsigned := 0) is record
      case discr is
         when 0 =>
         c_type : aliased SDL_stdinc_h.Uint8;  -- SDL_events.h:221:8
         when 1 =>
         active : aliased t_SDL_ActiveEvent;  -- SDL_events.h:222:18
         when 2 =>
         key : aliased SDL_KeyboardEvent;  -- SDL_events.h:223:20
         when 3 =>
         motion : aliased SDL_MouseMotionEvent;  -- SDL_events.h:224:23
         when 4 =>
         button : aliased SDL_MouseButtonEvent;  -- SDL_events.h:225:23
         when 5 =>
         jaxis : aliased SDL_JoyAxisEvent;  -- SDL_events.h:226:19
         when 6 =>
         jball : aliased SDL_JoyBallEvent;  -- SDL_events.h:227:19
         when 7 =>
         jhat : aliased SDL_JoyHatEvent;  -- SDL_events.h:228:18
         when 8 =>
         jbutton : aliased SDL_JoyButtonEvent;  -- SDL_events.h:229:21
         when 9 =>
         resize : aliased SDL_ResizeEvent;  -- SDL_events.h:230:18
         when 10 =>
         expose : aliased SDL_ExposeEvent;  -- SDL_events.h:231:18
         when 11 =>
         quit : aliased SDL_QuitEvent;  -- SDL_events.h:232:16
         when 12 =>
         user : aliased t_SDL_UserEvent;  -- SDL_events.h:233:16
         when others =>
         syswm : aliased t_SDL_SysWMEvent;  -- SDL_events.h:234:17
      end case;
   end record;
   pragma Convention (C, SDL_Event);
   pragma Unchecked_Union (SDL_Event);  -- SDL_events.h:220:25

  -- Function prototypes
  -- Pumps the event loop, gathering events from the input devices.
  --   This function updates the event queue and internal input device state.
  --   This should only be run in the thread that sets the video mode.
  --

   procedure SDL_PumpEvents;  -- SDL_events.h:244:49
   pragma Import (C, SDL_PumpEvents, "SDL_PumpEvents");

  -- Checks the event queue for messages and optionally returns them.
  --   If 'action' is SDL_ADDEVENT, up to 'numevents' events will be added to
  --   the back of the event queue.
  --   If 'action' is SDL_PEEKEVENT, up to 'numevents' events at the front
  --   of the event queue, matching 'mask', will be returned and will not
  --   be removed from the queue.
  --   If 'action' is SDL_GETEVENT, up to 'numevents' events at the front
  --   of the event queue, matching 'mask', will be returned and will be
  --   removed from the queue.
  --   This function returns the number of events actually stored, or -1
  --   if there was an error.  This function is thread-safe.
  --

   subtype SDL_eventaction is unsigned;
   SDL_ADDEVENT : constant SDL_eventaction := 0;
   SDL_PEEKEVENT : constant SDL_eventaction := 1;
   SDL_GETEVENT : constant SDL_eventaction := 2;  -- SDL_events.h:262:3

  --
   function SDL_PeepEvents
     (events : access SDL_Event;
      numevents : int;
      action : SDL_eventaction;
      mask : SDL_stdinc_h.Uint32) return int;  -- SDL_events.h:265:40
   pragma Import (C, SDL_PeepEvents, "SDL_PeepEvents");


   -- Waits indefinitely for the next available event,
   -- returning the event or raising excetption if there was an error
   function Wait_Event return Sdl_Event;

   -- Return the type of the event
   function Type_Of (Event : Sdl_Event) return Sdl_Eventtype;


  -- Polls for currently pending events, and returns 1 if there are any pending
  --   events, or 0 if there are none available.  If 'event' is not NULL, the next
  --   event is removed from the queue and stored in that area.
  --

--     function SDL_PollEvent (event : access SDL_Event) return int;  -- SDL_events.h:271:59
--     pragma Import (C, Sdl_Pollevent, "SDL_PollEvent");

   function Sdl_Pollevent (Event : access Sdl_Event) return Boolean;

  -- Add an event to the event queue.
  --   This function returns 0 on success, or -1 if the event queue was full
  --   or there was some other error.
  --

   function SDL_PushEvent (event : access SDL_Event) return int;  -- SDL_events.h:283:59
   pragma Import (C, SDL_PushEvent, "SDL_PushEvent");

  --  This function sets up a filter to process all events before they
  --  change internal state and are posted to the internal event queue.
  --  The filter is protypted as:
  --

   type SDL_EventFilter is access function (arg1 : access constant SDL_Event) return int;  -- SDL_events.h:291:62

  --  If the filter returns 1, then the event will be added to the internal queue.
  --  If it returns 0, then the event will be dropped from the queue, but the
  --  internal state will still be updated.  This allows selective filtering of
  --  dynamically arriving events.
  --  WARNING:  Be very careful of what you do in the event filter function, as
  --            it may run in a different thread!
  --  There is one caveat when dealing with the SDL_QUITEVENT event type.  The
  --  event filter is only called when the window manager desires to close the
  --  application window.  If the event filter returns 1, then the window will
  --  be closed, otherwise the window will remain open if possible.
  --  If the quit event is generated by an interrupt signal, it will bypass the
  --  internal queue and be delivered to the application at the next event poll.
  --

   procedure SDL_SetEventFilter (filter : access function (arg1 : access constant SDL_Event) return int);  -- SDL_events.h:308:71
   pragma Import (C, SDL_SetEventFilter, "SDL_SetEventFilter");

  --  Return the current event filter - can be used to "chain" filters.
  --  If there is no event filter set, this function returns NULL.
  --

   function SDL_GetEventFilter return access function (arg1 : access constant SDL_Event) return int;  -- SDL_events.h:314:64
   pragma Import (C, SDL_GetEventFilter, "SDL_GetEventFilter");

  --  This function allows you to set the state of processing certain events.
  --  If 'state' is set to SDL_IGNORE, that event will be automatically dropped
  --  from the event queue and will not event be filtered.
  --  If 'state' is set to SDL_ENABLE, that event will be processed normally.
  --  If 'state' is set to SDL_QUERY, SDL_EventState() will return the
  --  current processing state of the specified event.
  --

   function SDL_EventState (c_type : SDL_stdinc_h.Uint8; state : int) return SDL_stdinc_h.Uint8;  -- SDL_events.h:328:67
   pragma Import (C, SDL_EventState, "SDL_EventState");

  -- Ends C function definitions when using C++
end SDL_events_h;
